package org.minos.edit.view
{
	import flash.events.Event;
	import org.aswing.JOptionPane;
	import org.minos.edit.EditFacate;
	import org.minos.edit.events.EditEvent;
	import org.minos.edit.Main;
	import org.minos.edit.model.ClearProxy;
	import org.minos.edit.model.vo.DialogVO;
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	/**
	 * ...
	 * @author Minos
	 */
	public class EditMediator extends Mediator
	{
		public static const NAME : String = "EditMediator";
		
		public function EditMediator( v : Main )
		{
			super( NAME , v );
		}
		
		public function get edit() : Main
		{
			return viewComponent as Main;
		}
		
		override public function onRegister() : void
		{
			super.onRegister();
			edit.addEventListener( Main.DRAG_DROP , __onDragDrop );
		}
		
		/**
		 *
		 * @param	e
		 */
		private function __onDragDrop( e : EditEvent ) : void
		{
			switch ( e.data.type )
			{
				//文件夹
				case "dir":
					break;
				//文件
				case "open": 
					var cp : ClearProxy = facade.retrieveProxy( ClearProxy.NAME ) as ClearProxy;
					cp.clear();
					sendNotification( EditFacate.READ_FILE , e.data.data );
					break;
				//其他格式
				case "error": 
					var vo : DialogVO = new DialogVO();
					vo.title = "错误";
					vo.msg = "文件格式错误！！";
					vo.button = JOptionPane.OK;
					sendNotification( EditFacate.SHOW_DIALOG , vo );
					break;
				default: 
			}
		}
	
	}

}